package planosSaude;
/**
 * Hugo Guttemberg 
 */
import util.RepositorioException;

public class CadastroPlanosSaude {
	private RepositorioPlanosSaude planosSaude;
	
	public CadastroPlanosSaude (RepositorioPlanosSaude planosSaude){
		this.planosSaude = planosSaude;
	}
	
	public void cadastrar(PlanoSaude planoSaude) throws RepositorioException, PlanoSaudeEncontradoException{
		if(! this.planosSaude.existe(planoSaude.getCodigo())){
			planosSaude.inserir(planoSaude);
		} else {
			throw new PlanoSaudeEncontradoException(planoSaude.getCodigo());
		}
	}
	
	public void remover (long codigo) throws PlanoSaudeNaoEncontradoException, RepositorioException{
		planosSaude.remover(codigo);
	}	
	
	public void atualizar(PlanoSaude planoSaude) throws PlanoSaudeNaoEncontradoException, RepositorioException{
		planosSaude.atualizar(planoSaude);
	}
	
	public PlanoSaude procurar(long codigo) throws PlanoSaudeNaoEncontradoException, RepositorioException{
		return planosSaude.procurar(codigo);
	}
	
	public RepositorioPlanosSaude procurar(PlanoSaude planoSaude) throws RepositorioException, PlanoSaudeEncontradoException, PlanoSaudeNaoEncontradoException{
		return planosSaude.procurar(planoSaude);
	}
	public boolean existe(long codigo) throws RepositorioException {
		return this.planosSaude.existe(codigo);
	}	

	public IteratorPlanosSaude getPlanos() throws RepositorioException {
		return this.planosSaude.getIterator();
	}
}
